// 判断计划是否过期
export function isPlanExpired(timeInput) {
	let ddl = new Date(timeInput);
	let now = Date.now();

	if ((ddl - now) >= 0) {
		return false
	} else {
		return true
	}
}

// 判断今天签到了没，检查最近的一次签到日期是否为当天之前 传入xxxx-xx-xx
export function isCheckedToday(dateInput) {
	
	let dateNowStr = ''
	let dateNow = new Date()
    let fullYear = dateNow.getFullYear().toString().padStart(2, 0)
	let month = (dateNow.getMonth() + 1).toString().padStart(2, 0)
	let date = dateNow.getDate().toString().padStart(2, 0)
	dateNowStr = `${fullYear}-${month}-${date}`
	
	let curdate = new Date(dateNowStr)
	let checkedDate = new Date(dateInput)
	
	if(checkedDate < curdate) {
	  return false
	}else {
	  return true
	}
}

// 获取当前时间 返回 xxxx-xx-xx
export function getNowDateStr() {
	let dateNowStr = ''
	let dateNow = new Date()
  
    let fullYear = dateNow.getFullYear().toString().padStart(2, 0)
	let month = (dateNow.getMonth() + 1).toString().padStart(2, 0)
	let date = dateNow.getDate().toString().padStart(2, 0)

	dateNowStr = `${fullYear}-${month}-${date}`
  
	return dateNowStr
}

// 获取当前时间 返回 xxxx-xx-xx xx:xx:xx
export function getNowDateStrFull() {
	let dateNowStr = ''
	let dateNow = new Date()
  
    let fullYear = dateNow.getFullYear().toString().padStart(2, 0)
	let month = (dateNow.getMonth() + 1).toString().padStart(2, 0)
	let date = dateNow.getDate().toString().padStart(2, 0)
	
	let hour = dateNow.getHours().toString().padStart(2, 0);
	let minute = dateNow.getMinutes().toString().padStart(2, 0); 
	let second = dateNow.getSeconds().toString().padStart(2, 0);

	dateNowStr = `${fullYear}-${month}-${date} ${hour}:${minute}:${second}`
	return dateNowStr
}

// 判断是否在时间段内（开始时间，截至时间，需要判断的选中它时间）
export function isDuringDate(startTime, endTime, selectedTime) {
  let start = new Date(startTime)
  let end = new Date(endTime)
  let selected = new Date(selectedTime)

  if(start <= selected && selected <= end) {
    return true
  }else {
    return false
  }
}